
#ifndef _TTG_EXTRAS_SERIALIZATION_BYTEDESERIALIZER_
#define _TTG_EXTRAS_SERIALIZATION_BYTEDESERIALIZER_

#include "DeSerializer.h"

namespace ttg
{
	namespace extras
	{
		namespace serialization
		{
			//Deserializes objects from a byte stream.
			class ByteDeSerializer :public DeSerializer
			{
				private:
					unsigned char *data;
					size_t data_size;
					size_t current;
					bool is_safe;
				private:
					//Reads serialized hash value from the byte stream.
					unsigned __int32 readHash();
					//Ensures that stream contains enough data.
					//In case of error throws ttg::Error.
					void checkData(size_t size);
				protected:
					//DeSerializer member.
					virtual void deserializeMemory(void *data, size_t size, const char *name);
					//DeSerializer member.
					virtual void deserializeReferenceStart(bool &is_null, const char *name);
					//DeSerializer member.
					virtual void deserializeReferenceEnd(const char *name);
				public:
					ByteDeSerializer(void *data, size_t size);
			};
		}
	}
}

#endif
